package com.qf.provider;

import com.qf.pojo.TbUser;

/**
 * @author langazhe
 * @version V1.0
 * @Project mybatis02
 * @Package com.qf.provider
 * @Description:
 * @Date 2022/5/19 17:32
 */
public class MyUserProvider {

    public String updateUser( TbUser tbUser){
        StringBuffer stringBuffer=new StringBuffer("update tb_user set ");
        //根据自己的实际要做的事情拼接sql语句
        if(tbUser.getCode()!=null && !"".equals(tbUser.getCode().trim())){
            stringBuffer.append("code =").append("#{code}").append(",");
        }
        if(tbUser.getNickName()!=null && !"".equals(tbUser.getNickName().trim())){
            stringBuffer.append("nick_name =").append("#{nickName}").append(",");
        }
        if(tbUser.getEmail()!=null && !"".equals(tbUser.getEmail().trim())){
            stringBuffer.append("email =").append("#{email}").append(",");
        }
        //删除最后一个逗号
        stringBuffer.deleteCharAt(stringBuffer.length()-1);
        stringBuffer.append(" where id=").append("#{id}");
        String sql = stringBuffer.toString();
        System.err.println(sql);
        return sql;
    }
}
